<template>
  <div id="table">
    <el-form label-width="10px" class="form-container" :model="postForm" ref="postForm">
    <el-row>
      <el-input v-model="postForm.deviceCode" style="width:200px"placeholder="请输入设备代码" ></el-input>
      <el-button type="primary" @click="searchDevice">搜索设备</el-button>
      <el-button type="primary" @click="handleDelete">删除设备</el-button>
      <el-button type="primary" @click="show">查看所有</el-button>
      <router-link  class="filter-item" to="/otherdata/productdesign/create">
        <el-button type="primary">添加设备</el-button>
      </router-link>
    </el-row>

      <el-table
        :data="productTable" border style="width: 100%">
        <el-table-column label="设备名称" width="200" prop="deviceName"/>
        <el-table-column label="容器类别" width="200" prop="containerType"/>
        <el-table-column label="设备代码" width="200" prop="deviceCode"/>
        <el-table-column label="使用登记证编号" width="200" prop="registerCode"/>
        <el-table-column label="单位内编号" width="200" prop="unitCode"/>
        <el-table-column label="制造单位" width="200" prop="makeUnit"/>
        <el-table-column label="安装单位" width="200" prop="installUnit"/>
        <el-table-column label="使用单位" width="200" prop="useUnit"/>
        <el-table-column label="使用单位地址" width="200" prop="useUnitAdress"/>
        <el-table-column label="设备使用地点" width="200" prop="usePosition"/>
        <el-table-column label="使用单位组织机构代码" width="200" prop="useUnitCode"/>
        <el-table-column label="安全管理人员" width="200" prop="safeManager"/>
        <el-table-column label="联系电话" width="200" prop="telephone"/>
        <el-table-column label="设计使用年限" width="200" prop="useLife"/>
        <el-table-column label="使用投入日期" width="200" prop="useDate"/>
        <el-table-column label="主体机构形式" width="200" prop="subjectStructureForm"/>
        <el-table-column label="运行状态" width="200" prop="state"/>
        <el-table-column label="容积" width="200" prop="volume"/>
        <el-table-column label="内径" width="200" prop="internalDiameter"/>
        <el-table-column label="设计压力" width="200" prop="designPressure"/>
        <el-table-column label="设计温度" width="200" prop="designTemperature"/>
        <el-table-column label="使用压力" width="200" prop="usePressure"/>
        <el-table-column label="使用温度" width="200" prop="useTemperature"/>

        <!--<el-table-column align="center" label="操作" width="200">-->
          <!--<template slot-scope="scope">-->
            <!--<el-button type="primary" size="mini" icon="el-icon-edit" v-show="!scope.row.root" @click="editPeople(scope.row.deviceCode)">编辑</el-button>-->
            <!--<el-button type="danger" size="mini" icon="el-icon-delete" @click="handleDelete(scope.row.deviceCode)" v-show="!scope.row.root">删除</el-button>-->
          <!--</template>-->
        <!--</el-table-column>-->

    </el-table>
    </el-form>
  </div>
</template>

<script>
  import { req } from '@/api/base/BaseApi'
  const defaultForm = {
    deviceName: undefined,
    containerType: undefined,
    deviceCode: undefined
  }
  export default {
    name: 'index',
    data() {
      return {
        deviceCode: [],
        module: 'productBaseInfo',
        testTable: [],
        input1: '',
        productTable: [],
        listLoading: true,
        listQuery: {
          page: 1,
          size: 10,
          keyword: undefined
        },
        total: 0,
        list: null,

        postForm: Object.assign({},defaultForm)
      }
    },
    mounted: function() {
      this.show()
      this.postForm = Object.assign({}, defaultForm)
    },
    methods: {
      get: function() {
      },
      show() {
        req('/coketower-service/productBaseInfo/allList', 'GET', '').then(response => {
          this.productTable = response.data
          console.log(this.productTable)
        }).catch(() => console.log('page request error'))
      },
      searchDevice() {
        console.log(this.postForm)
        req('/coketower-service/productBaseInfo' , 'GET',this.postForm).then(response => {
          this.productTable = response.data
        }).catch(() => console.log('page request error'))
      },
      handleDelete() {
        req('/coketower-service/productBaseInfo/' + this.postForm.deviceCode, 'DELETE').then(response => {
          this.show()
        }).catch(() => console.log('page request error'))
        this.$message('删除成功！')
      },
      editPeople(deviceCode) {
        this.$router.push({ path: '/otherdata/productdesign/edit', query: { deviceCode: deviceCode }})
      }
    }
  }
</script>

<style scoped>
  h1{
    font-weight: normal;
    text-align: center;
    color: #808080;
    font-size: 25px;
  }
</style>
